<template>
	<div class="coin-com">
		<giantScreen :userInfo="userInfo"></giantScreen>
		<scroll>
			<sign :userInfo="userInfo" @handleRefresh='handleRefresh'></sign>
			<vipList v-if="viplist.length"></vipList>
			<rankList :list="timerank"></rankList>
		</scroll>
	</div>
</template>

<script>
	import {
		getUserSession,
		getRankListData,
	} from '@/api/coin.js'
	import {
		userInfoMixin
	} from '@/mixins/userInfo.js'
	import giantScreen from '@/components/coin/giantScreen.vue'
	import scroll from '@/components/coin/scroll.vue'
	import sign from '@/components/coin/sign.vue'
	import vipList from '@/components/coin/vipList.vue'
	import rankList from '@/components/coin/rankList.vue'
	export default {
		mixins: [userInfoMixin],
		components: {
			giantScreen,
			scroll,
			sign,
			vipList,
			rankList,
		},
		data() {
			return {
				// userInfo: {},
				viplist: [],
				timerank: [],
				coinrank: [],
			}
		},
		async mounted() {
			this.$emit('setLoading', true)
			await this.userInfo_init()
			await this.getRankList()
			this.$emit('setLoading', false)
		},
		methods: {
			handleRefresh() {
				this.getUserInfoByLogin() // 通过重新请求登录接口获取userInfo 更新数据
				this.getRankList()
			},
			async getRankList() {
				const res = await getRankListData()
				if (res) {
					this.timerank = res.data.timerank
					this.coinrank = res.data.coinrank
					// console.log(this.timerank, this.coinrank);
				} else {
					uni.showToast({
						title: '请求失败',
						icon: 'error'
					})
				}
			},
		},
	}
</script>

<style lang="scss" scoped>
	.coin-com {}
</style>